<template>
  <div class="ma-content-block lg:flex justify-between p-4">
    <!-- CRUD 组件 -->
    <ma-crud :options="options" :columns="columns" ref="crudRef">
      <template #operationBeforeExtend="{ record }">
        <a-link @click="openDictList(record)"><icon-list />服务列表</a-link>
      </template>
    </ma-crud>
    <data-list ref="datalist" />
  </div>
</template>
<script setup>
import { ref, reactive } from 'vue'
import area from '@/api/warehouse/area'
import { Message } from '@arco-design/web-vue'
import tool from '@/utils/tool'
import * as common from '@/utils/common'
import DataList from './dataList.vue'
const crudRef = ref()
const datalist = ref()

const openDictList = async (row) => {
  datalist.value.open(row)
}

const options = reactive({
  id: 'area',
  pageLayout: 'fixed',
  rowSelection: {
    showCheckedAll: true
  },
  pk: 'id',
  operationColumn: true,
  operationColumnWidth: 160,
  formOption: {
    viewType: 'drawer',
    width: "80%"
  },
  api: area.getList,
  add: {
    show: true,
    api: area.save,
    auth: ['warehouse:area:save']
  },
  edit: {
    show: true,
    api: area.update,
    auth: ['warehouse:area:update']
  },
  delete: {
    show: true,
    api: area.deletes,
    auth: ['warehouse:area:delete']
  }
})

const columns = reactive([
  {
    title: "主键",
    dataIndex: "id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    commonRules: {
      required: true,
      message: "请输入主键"
    }
  },
  {
    title: "名称",
    dataIndex: "name",
    formType: "input",
    commonRules: {
      required: true,
      message: "请输入名称"
    }
  },
  // {
  //   title: "国家",
  //   dataIndex: "country",
  //   formType: "select",
  //   dict: {
  //     name: "countrys",
  //     props: {
  //       label: "title",
  //       value: "key"
  //     },
  //     translation: true
  //     },
  //   multiple:true  
  // },
  // {
  //   title: "邮编开头",
  //   dataIndex: "postcode",
  //   formType: "input",
  // },
  // {
  //   title: "地址库",
  //   dataIndex: "address",
  //   formType: "select",
  //   virtualListProps:{},
  //   dict: {
  //      url: 'logistics/addressLibDetail/list',
  //       props: {label: 'code', value: 'id'},
  //       params:{
  //         select:'id,code'
  //       },
  //       translation: true,
  //     },
  //   multiple:true  
  // },

  {
    title: "创建者",
    dataIndex: "created_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "更新者",
    dataIndex: "updated_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "创建时间",
    dataIndex: "created_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "更新时间",
    dataIndex: "updated_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "删除时间",
    dataIndex: "deleted_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "备注",
    dataIndex: "remark",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  }
])
</script>
<script> export default { name: 'warehouse:area' } </script>